Repository navigation
Move telemetry auth helpers from cmd/aitools to cmd/root - #8158
simonfaltum wants to merge 2 commits into
Conversation
WithTelemetryAuth, TelemetryAuth and their helpers move into cmd/root, together with the agent type mapping and CallingAgentType, so cmd/skills no longer imports cmd/aitools. This is a pure move with no behaviour change: the aitools and skills acceptance tests are unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/cmd/skills/telemetry: branch ✅ | main (e6f3460) ❌ | latest (v1.28.0) ❌main (e6f3460): latest (v1.28.0): |
✅ Integration test reportCommit: 3f8d9fc
Top 6 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at df722a4. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) and 1 question(s) below.
This PR moves the telemetry auth helpers (WithTelemetryAuth, TelemetryAuth, the budget and resolver) from cmd/aitools to cmd/root/telemetry_auth.go, and AgentType/CallingAgentType to cmd/root/root.go, so cmd/skills no longer imports cmd/aitools. The moved production code matches the base version, apart from the renames, and every call site points to the new locations. What's left is cleanup: the two moved tests were rewritten into one instead of being moved as they were, and the registry coverage test for AgentType still sits in cmd/aitools and refers to the old function name.
Questions
AgentTypeandCallingAgentTypeonly maplibs/aitools/agentsnames toprotosvalues, and nothing incmd/rootcalls them. Theroot-aitools-hooks-in-root-golint rule exists for the root pre/post-run hooks, and the depguard message says shared aitools code should go throughlibs/aitools. Should these two functions live inlibs/aitools(for examplelibs/aitools/agents) instead? Or, if they stay inroot.go, should that lint rule's comment mention this use? (non-blocking)
| // A resolution that has already finished still counts, with or without the | ||
| // wait, even once the budget has passed. The repeats make a race between | ||
| // "done" and "not done" fail reliably. | ||
| func TestTelemetryAuthFinishedResolutionSurvivesAnExpiredBudget(t *testing.T) { |
There was a problem hiding this comment.
[nice to have] TestTelemetryAuthFinishedResolutionSurvivesAnExpiredBudget and TestTelemetryAuthNoWaitUsesFinishedResolution from cmd/aitools/telemetry_auth_test.go are now one table-driven test. The second name is gone, and the authTestCmd fixture (--profile flag, WithTelemetryAuth with WaitAtExit) is replaced by a bare cobra.Command and inline setup. That means this "no behaviour change" move can't be checked as a straight copy. AGENTS.md asks that moved code not be changed along the way. Can we move both tests unchanged, with a small local helper, and do the table-driven merge separately?
There was a problem hiding this comment.
Done in 3f8d9fc. Both tests are back in cmd/root unchanged, from the parent branch, with their shared setup in two small local helpers (setTelemetryAuth and authTestCmd). The table-driven merge is not in this pull request. It can follow as its own change.
| for _, a := range agents.Registry { | ||
| assert.NotEqualf(t, protos.AitoolsAgentTypeUnspecified, agentType(a.Name), | ||
| assert.NotEqualf(t, protos.AitoolsAgentTypeUnspecified, root.AgentType(a.Name), | ||
| "agent %q has no telemetry enum: add a case to agentType and a value to "+ |
There was a problem hiding this comment.
[nice to have] AgentType now lives in cmd/root/root.go, but TestAgentTypeCoversRegistry stays in cmd/aitools. Someone who adds a case and runs go test ./cmd/root/... never runs the guard, even though the doc comment on root.AgentType names it as if it sat next to the function. The failure message here and the test's comment on line 73 also still say agentType. Can we move the test to cmd/root, which already imports libs/aitools/agents in root.go, and update the name to AgentType?
There was a problem hiding this comment.
Done in 3f8d9fc. TestAgentTypeCoversRegistry moved to cmd/root/root_test.go, next to root.AgentType. The failure message and the doc comment now name root.AgentType.
Move the two cmd/aitools auth tests into cmd/root unchanged, with small local helpers, instead of merging them into one table-driven test. Move TestAgentTypeCoversRegistry to cmd/root next to root.AgentType and name root.AgentType in its failure message and comment. Co-authored-by: Isaac <no-reply@databricks.com>
Changes
cmd/skillsimportscmd/aitoolsonly for the telemetry auth helpers and the calling-agent mapping. This PR moves those intocmd/rootand pointscmd/skillsthere, so the skills commands no longer importcmd/aitools. It is stacked on #8145 (baseskills/t1-telemetry-for-the-skills-commands) and has no behaviour change.WithTelemetryAuth,TelemetryAuth, their helpers and the wait budget move fromcmd/aitools/telemetry.gotocmd/root/telemetry_auth.go.AgentType(the agent registry to telemetry enum mapping) andCallingAgentTypemove tocmd/root/root.go.cmd/skillsimportscmd/rootinstead ofcmd/aitools.root.AgentType,root.CallingAgentType,root.WithTelemetryAuthandroot.TelemetryAuthBudget.Why
The lint config lets
cmd/aitoolsimport onlycmd/rootand itself, so code that both command groups share belongs incmd/root. The move is a separate pull request so that reviewers can check it without the behaviour changes in #8145.Decisions to review
TelemetryAuthBudgetandTelemetryAuthResolverare exported package variables. The aitools tests in another package stub them to keep install and update tests off the host's auth. The alternative was a test-only export file, which the other package cannot import.AgentTypeandCallingAgentTypego inroot.go, the onlycmd/rootfile that may importlibs/aitools, under theroot-aitools-hooks-in-root-golint rule.cmd/root/telemetry_auth_test.go. The rest of the aitools telemetry auth tests stay where they are.TestAgentTypeCoversRegistrymoves tocmd/root/root_test.go, next toAgentTypethat it guards.Tests
go test ./cmd/root/... ./cmd/aitools/... ./cmd/skills/...passes.TestTelemetryAuthFinishedResolutionSurvivesAnExpiredBudgetcovers the moved wait behaviour.go test ./acceptance -run 'TestAccept/cmd/aitools'and-run 'TestAccept/cmd/skills'pass with no golden changes../task --force fmt-q lint-q,./task aitools-quickand the deadcode check pass.This pull request and its description were written by Isaac.